<script language="javascript" src="modules/VoteDataCenter/pnajax/ajax_form_house_no.js"></script>
<script type="text/javascript">
    function validateForm(form) {
      //Check pro_id
      var pro_id = document.getElementById("form_pro_id_");
      if (pro_id.value == '0') {
          alert("กรุณาเลือกจังหวัด");
          pro_id.style.borderStyle = "solid";
          pro_id.style.borderColor = "#FF0000";
          pro_id.style.borderWidth = "1px";
          pro_id.focus();
          return false;
      }else{
          pro_id.style.borderStyle = "solid";
          pro_id.style.borderColor = "#00CC00";
          pro_id.style.borderWidth = "1px";
      }
      
      var dis_id = document.getElementById("form_dis_id_");
      if (dis_id.value == '0') {
          alert("กรุณาเลือกอำเภอ");
          dis_id.style.borderStyle = "solid";
          dis_id.style.borderColor = "#FF0000";
          dis_id.style.borderWidth = "1px";
          dis_id.focus();
          return false;
      }else{
          dis_id.style.borderStyle = "solid";
          dis_id.style.borderColor = "#00CC00";
          dis_id.style.borderWidth = "1px";
      }
      
      var tam_id = document.getElementById("form_tam_id_");
      if (tam_id.value == '0') {
          alert("กรุณาเลือกตำบล");
          tam_id.style.borderStyle = "solid";
          tam_id.style.borderColor = "#FF0000";
          tam_id.style.borderWidth = "1px";
          tam_id.focus();
          return false;
      }else{
          tam_id.style.borderStyle = "solid";
          tam_id.style.borderColor = "#00CC00";
          tam_id.style.borderWidth = "1px";
      }
      
      
      //Check category
      var vil_id = document.getElementById("form_vil_id_");
      if(vil_id){
        if (vil_id.value == '0') {
            alert("กรุณาเลือกหมู่บ้าน");
            vil_id.style.borderStyle = "solid";
            vil_id.style.borderColor = "#FF0000";
            vil_id.style.borderWidth = "1px";
            vil_id.focus();
            return false;
        }else{
            vil_id.style.borderStyle = "solid";
            vil_id.style.borderColor = "#00CC00";
            vil_id.style.borderWidth = "1px";
        }
      }
/*
      //Check party
      var party = document.getElementById("form_par_id_");
      if (party.value == '0') {
          alert("กรุณาเลือกพรรค ");
          party.style.borderStyle = "solid";
          party.style.borderColor = "#FF0000";
          party.style.borderWidth = "1px";
          party.focus();
          return false;
      }else{
          party.style.borderStyle = "solid";
          party.style.borderColor = "#00CC00";
          party.style.borderWidth = "1px";
      }
*/
      //Check house_no
      var house_no = document.getElementById("no");
      if (house_no.value == '') {
          alert("กรุณาบอกบ้านเลขที่ ");
          house_no.style.borderStyle = "solid";
          house_no.style.borderColor = "#FF0000";
          house_no.style.borderWidth = "1px";
          house_no.focus();
          return false;
      }else{
          house_no.style.borderStyle = "solid";
          house_no.style.borderColor = "#00CC00";
          house_no.style.borderWidth = "1px";
      }

      //Check title
      var title = document.getElementById("title");
      if (title.value == '') {
          alert("กรุณากรอกหัวข้อปัญหา");
          title.style.borderStyle = "solid";
          title.style.borderColor = "#FF0000";
          title.style.borderWidth = "1px";
          title.focus();
          return false;
      }else{
          title.style.borderStyle = "solid";
          title.style.borderColor = "#00CC00";
          title.style.borderWidth = "1px";
      }
      
      //Check latitude
      var latitude = document.getElementById("latitude");
      if (latitude.value == '') {
          alert("Please enter value.");
          latitude.style.borderStyle = "solid";
          latitude.style.borderColor = "#FF0000";
          latitude.style.borderWidth = "1px";
          latitude.focus();
          return false;
      }else{
          document.getElementById('error-title').innerHTML = "";
      }

      //Check longitude
      var longitude = document.getElementById("longitude");
      if (longitude.value == '') {
          alert("Please enter value.");
          longitude.style.borderStyle = "solid";
          longitude.style.borderColor = "#FF0000";
          longitude.style.borderWidth = "1px";
          longitude.focus();
          return false;
      }else{
          document.getElementById('error-longitude').innerHTML = "";
      }

    }
</script>

</head>
<TABLE width="100%" >
  <TR>
    <TD valign="top" border="1">
        <fieldset>
          <legend>&nbsp;เพิ่มรายชื่อผู้มีสิทธิ&nbsp;</legend>
            <form id='form' 
                  class='form' 
                  action="<!--[pnmodurl modname='VoteDataCenter' type='userform' func='submit' ctrl='ExtPerson']-->" 
                  method="post" 
                  onsubmit="return validateForm(this)"
            >
                <input type="hidden" name="form[id]" value="<!--[$smarty.request.id]-->" />
                <TABLE width='100%' border="0">

                  <tr>
                    <td>
                        <!--[selector_object_array_ex
                              modname="VoteDataCenter" 
                              class="Gender" 
                              field="id" 
                              displayField="name"  
                              name="form[gen_id]" 
                              selectedValue=$form.gen_id 
                              defaultValue="0"
                              defaultText="--------- กรุณาเลือก ---------"
                        ]-->
                    </td>
                  </tr>

                    <TR>
                      <TD class='td-label' align="left">
                        <B>จังหวัด&nbsp;:&nbsp;</B>
                      </TD>
                    </TR>
                    <TR>
                      <TD align="left">
                        <!--[selector_object_array_ex
                              modname="VoteDataCenter" 
                              class="Province" 
                              field="id" 
                              displayField="name"  
                              name="form[pro_id]" 
                              selectedValue=$form.pro_id 
                              sort="pro_name"
                              onChange="getDistrictByProvinceID()"
                              onClick="getDistrictByProvinceID()"
                              defaultValue="0"
                              defaultText="--------- กรุณาเลือก ---------"
                        ]-->
                        <FONT SIZE="2" COLOR="#FF0000">&nbsp;*</FONT>
                      </TD>
                    </TR>
                    <TR>
                      <TD class='td-label' align="left">
                        <B>อำเภอ&nbsp;:&nbsp;</B>
                      </TD>
                    </TR>
                    <TR>
                      <TD align="left">
                        <span id="form_district">
                            <!--[if (isset($smarty.request.form.dis_id) || $smarty.request.form.dis_id == 0) && $smarty.request.form.pro_id]-->
                              <!--[selector_object_array_ex modname="VoteDataCenter" 
                                      class="District" 
                                      field="id" 
                                      displayField="name"  
                                      name="form[dis_id]" 
                                      sort="dis_name"
                                      selectedValue=$smarty.request.form.dis_id
                                      queryField = dis_pro_id
                                      queryValue = $smarty.request.form.pro_id
                                      onChange="getTambonByDistrictID()"
                              ]-->
                            <!--[elseif $form.dis_id && $form.pro_id]-->
                              <!--[selector_object_array_ex modname="VoteDataCenter" 
                                      class="District" 
                                      field="id" 
                                      displayField="name"  
                                      name="form[dis_id]" 
                                      sort="dis_name"
                                      selectedValue=$form.pro_id
                                      queryField = dis_pro_id
                                      queryValue = $form.pro_id
                                      onChange="getTambonByDistrictID()"
                              ]-->
                            <!--[else]-->
                            -
                            <!--[/if]-->
                        </span>
                        <div id='error-name'></div>
                      </TD>
                    </TR>
                    <TR>
                      <TD class='td-label' align="left">
                        <B>ตำบล&nbsp;:&nbsp;</B>
                      </TD>
                    </TR>
                    <TR>
                      <TD align="left">
                        <span id="form_tambon">
                            <!--[if (isset($smarty.request.form.tam_id) || $smarty.request.form.tam_id == 0) && $smarty.request.form.tam_id]-->
                              <!--[selector_object_array_ex 
                                      modname="VoteDataCenter" 
                                      class="Tambon" 
                                      field="id" 
                                      displayField="name"  
                                      name="form[tam_id]" 
                                      sort="tam_name"
                                      selectedValue=$smarty.request.form.tam_id
                                      queryField = dis_pro_id
                                      queryValue = $smarty.request.form.tam_id
                              ]-->
                            <!--[elseif $form.dis_id && $form.pro_id && $form.tam_id]-->
                              <!--[selector_object_array_ex 
                                      modname="VoteDataCenter" 
                                      class="Tambon" 
                                      field="id" 
                                      displayField="name"  
                                      name="form[tam_id]" 
                                      sort="tam_name"
                                      selectedValue=$form.tam_id
                                      queryField = tam_dis_id
                                      queryValue = $form.dis_id
                              ]-->
                            <!--[else]-->
                            -
                            <!--[/if]-->
                        </span>
                      </TD>
                    </TR>
                    <TR>
                      <TD class='td-label' align="left">
                        <B>หมู่&nbsp;:&nbsp;</B>
                      </TD>
                    </TR>
                    <TR>
                      <TD align="left">
                        <input type="text" name="form[vil_moo]" id="vill_moo"  value="<!--[$form.vil_moo]-->">
                        <FONT SIZE="2" COLOR="#FF0000">&nbsp;*</FONT>
                        <div id='error-name'></div>
                      </TD>
                    </TR>
                    <TR>
                      <TD class='td-label' align="left">
                        <B>บ้านเลขที่&nbsp;:&nbsp;</B>
                      </TD>
                    </TR>
                    <TR>
                      <TD align="left">
                        <input type="text" name="form[house_no]" id="no" value="<!--[$form.house_no]-->">
                        <FONT SIZE="2" COLOR="#FF0000">&nbsp;*</FONT>
                        <div id='error-name'></div>
                      </TD>
                    </TR>
                    <TR>
                      <TD class='td-label' align="left">
                        <B>ชื่อ&nbsp;:&nbsp;</B>
                      </TD>
                    </TR>
                    <TR>
                      <TD align="left">
                        <input type="text" name="form[firstname]" id="title" value="<!--[$form.firstname]-->">
                        <FONT SIZE="2" COLOR="#FF0000">&nbsp;*</FONT>
                        <div id='error-title'></div>
                      </TD>
                    </TR>
                    <TR>
                      <TD class='td-label' align="left">
                        <B>นามสกุล&nbsp;:&nbsp;</B>
                      </TD>
                    </TR>
                    <TR>
                      <TD align="left">
                        <input type="text" name="form[lastname]" id="title" value="<!--[$form.lastname]-->">
                        <FONT SIZE="2" COLOR="#FF0000">&nbsp;*</FONT>
                        <div id='error-title'></div>
                      </TD>
                    </TR>
                    <TR>
                      <TD align="left" width="100%">
                        <INPUT TYPE="submit" value="submit">
                        <input type="button" 
                                name="Cancel" 
                                value="Cancel" 
                                onclick="window.location = '<!--[pnmodurl modname='VoteDataCenter' type='user' func='list' ctrl='ExtPerson']-->' " 
                        />
                      </TD>
                    </TR>
                </TABLE>
            </form><BR>
        </fieldset><BR>
    </TD>
  </TR>
</TABLE>

